import HasRole from '@/components/Permi/hasRole.vue';
import hasPermi from '@/components/Permi/hasPermi.vue';
import IconFont from '@/components/IconFont/index.vue';
import CommonTable from '@/components/CommonTable/index.vue';
import CommonSearch from '@/components/CommonSearch/index.vue';
import CommonTreeselectV2 from '@/components/CommonTreeselectV2/index.vue';
import CommonDialogForm from '@/components/CommonDialogForm/index.js';
export default {
  install(Vue) {
    Vue.component('HasRole', HasRole);
    Vue.component('hasPermi', hasPermi);
    Vue.component('IconFont', IconFont);
    Vue.component('CommonTable', CommonTable);
    Vue.component('CommonSearch', CommonSearch);
    Vue.component('CommonTreeselectV2', CommonTreeselectV2);
    Vue.use(CommonDialogForm);
    // confirm二次封装
    Vue.config.globalProperties.$hyConfirm = function ({
      title = '提示',
      subTitle = '是否继续?',
      type = 'warning',
      callback = (done) => {
        done();
      }
    } = {}) {
      Vue.config.globalProperties
        .$confirm(subTitle, title, {
          type: type,
          beforeClose: (action, instance, done) => {
            if (action === 'confirm') {
              instance.confirmButtonLoading = true;
              instance.confirmButtonText = '执行中...';
              callback(done);
              instance.confirmButtonLoading = false;
            } else {
              done();
            }
          }
        })
        .then(() => {
          Vue.config.globalProperties.$message({
            type: 'success',
            message: '操作成功!'
          });
        });
    };
  }
};
